<template>
    <fieldset>
        <legend>计数器</legend>
        <button @click="DECREASE(2)">-</button>
        &nbsp;
        <b>{{$store.state.num}}</b>
        &nbsp;
        <button @click="INCREASE">+</button>
    </fieldset>
</template>
<script>
// state 组件共享的属性
// 使用辅助函数
import {mapState,mapMutations} from "vuex"
export default{
    mounted(){
        // console.log(this.$store.state);
        console.log(this.num);
    },
    computed:{
        ...mapState(['num'])
    },
    methods:{
        // handleMinus(){
        //     this.$store.commit("DECREASE",2)
        // },
        // handleAdd(){
        //     this.$store.commit("INCREASE")
        // }

        // 使用辅助函数
        ...mapMutations(['INCREASE','DECREASE'])
    }
}
</script>